<template>
    <el-drawer
        title="节点编辑"
        v-model="openFlag"
        :direction="direction">

      <el-form :model="form" label-width="auto" style="max-width: 600px">
        <el-form-item label="名称">
          <el-input v-model="form.name" />
        </el-form-item>
        <el-form-item label="审批人员">
          <el-select v-model="form.userId" placeholder="请选择审批人员">
            <el-option v-for="u in userList" :key="u.userId" :label="u.nickName" :value="u.userId" />

          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="sub">确定</el-button>
        </el-form-item>
      </el-form>
      </el-drawer>
  </template>

<script>
import { listAssetAuditUser } from "@/api/asset/assetAuditConfigNode";

    export default {
        name: "AssetAuditConfigNodeEdit",
        data() {
            return {
                openFlag: false,
                direction: 'rtl',
              index: 0,
              actionType: null,
              form: {
                name: '审核',
                userId: null,
                step: null,
                configId: null
              },
              userList: []
            }
        },
      mounted() {
        this.getUserList();
      },
        methods: {
            open(data) {

              this.index = data.index;
              const actionType = data.actionType;
              this.actionType = actionType;

              if (actionType === 'edit') {
                Object.assign(this.form, data.node);
              }
              this.openFlag = true;
            },
            close() {
                this.openFlag = false;
            },
          /** 查询资产审批配置列表 */
          getUserList() {
            listAssetAuditUser().then(response => {
              this.userList = response;
            });
          },
          sub() {
            debugger
              this.$emit('sub', {
                index: this.index,
                actionType: this.actionType,
                form: this.form
              });
            this.close();
          }
        }
    }
</script>